package dao

import (
	"github.com/e421083458/golang_common/lib"
	"github.com/e421083458/gorm"
	"github.com/gin-gonic/gin"
	"robotDaBai/app/common/middleware"
	"robotDaBai/public"
)

func GetDb(this *gin.Context) *gorm.DB {
	//得到db查询链接
	tx, err := lib.GetGormPool("default")
	if err != nil {
		middleware.ResponseError(this, 2000, err)
		return nil
	}
	//返回查询对象 并设置上下文
	return tx.SetCtx(public.GetGinTraceContext(this))
}
